/*
 * DrawerVisitor.hpp
 *
 *  Created on: 06-01-2011
 *      Author: Przemek
 */

#pragma once

#include "world/ElementsVisitor.hpp"
#include "geometry/CircleSlice.hpp"
#include "utils/GLColor.hpp"
#include "pch.hpp"

/*
 * Class which is responsible for buffered drawing of the world elements using openGL. When visiting
 * an element its remembered in vector. Drawing is made when the flush method is called. It also draws a
 * single rotated triangle around selected element (represented by a position vector).
 */
class DrawerVisitor: public ElementsVisitor
{
	private:
		boost::shared_ptr<Vector> selectedElementCenter;
		std::vector<Barrier*> barriers;
		std::vector<MeatSupply*> meatSupplies;
		std::vector<VegetableSupply*> vegetableSupplies;
		std::vector<WaterSupply*> waterSupplies;
		std::vector<Individual*> individuals;
		std::vector<CircleSlice> radars;

	public:
		void visit(Barrier& barrier);
		void visit(Individual& individual);
		void visit(MeatSupply& meatSupply);
		void visit(VegetableSupply& vegetableSupply);
		void visit(WaterSupply& waterSupply);
		void setSelectedElementCenter(const Vector& selectedElementCenter);
		void flush();

	private:
		void drawMeatSupplies();
		void drawBlackFramedRectangle(Element* element, const GLColor& color);
		void drawVegetableSupplies();
		void drawWaterSupplies();
		void drawBarriers();
		void drawIndividuals();
		void drawIndividual(Individual* individual);
		void drawRadars();
		void drawRadar(CircleSlice& radar);
		void markSelected();
};
